package com.gs.netty.client.remoting;

import com.gs.netty.client.Message;
import com.gs.netty.client.SendCallback;
import com.gs.netty.client.SendResult;
import com.gs.netty.client.exception.*;


/**
 * 远程调用接口
 */

public interface RemotingClient {


    /**
     * 同步发送

     */
    public SendResult send(Message message) throws WebSocketClientHandshakerException, WebSocketRemotingConnectException, WebSocketNotFountChannelException, WebSocketTooMuchRequestTimeoutException, WebSocketClientException;
    public <T> T send(Message message,Class<T> requiredType) throws WebSocketClientHandshakerException, WebSocketRemotingConnectException, WebSocketNotFountChannelException, WebSocketTooMuchRequestTimeoutException, WebSocketClientException;

    /**
     * 同步超时发送
     * @param timeoutMillis
     * @return
     */
    public SendResult send(Message message,long timeoutMillis) throws WebSocketClientHandshakerException, WebSocketRemotingConnectException, WebSocketNotFountChannelException, WebSocketTooMuchRequestTimeoutException, WebSocketClientException;

    public <T> T send(Message message,long timeoutMillis, Class<T> requiredType) throws WebSocketClientHandshakerException, WebSocketRemotingConnectException, WebSocketNotFountChannelException, WebSocketTooMuchRequestTimeoutException, WebSocketClientException;

    /**
     * 异步发送
     * @param commandRequest
     * @param sendCallback
     */
    public void send(Message commandRequest,  SendCallback sendCallback) throws WebSocketClientHandshakerException, WebSocketRemotingConnectException, WebSocketNotFountChannelException, WebSocketTooMuchRequestTimeoutException, WebSocketClientException;

    /**
     * 异步发送
     * @param commandRequest
     * @param sendCallback
     * @param timeoutMillis
     */
    public void send(Message commandRequest,SendCallback sendCallback,long timeoutMillis ) throws WebSocketClientHandshakerException, WebSocketRemotingConnectException, WebSocketNotFountChannelException, WebSocketTooMuchRequestTimeoutException, WebSocketClientException;

}
